<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   	xmlns:f="http://xmlns.jcp.org/jsf/core"
   	xmlns:h="http://xmlns.jcp.org/jsf/html"
   	xmlns:p="http://primefaces.org/ui"   
   	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
	
	<c:if test="#{not empty entityList.maxResults}">
		<div
			id="page"
			class="page_div"
		></div>
		<script>
		$("#page").paging({
			totalPage: #{empty entityList.pageCount ? 0 : entityList.pageCount},
			totalSize: #{empty entityList.resultCount ? 0 : entityList.resultCount},	
			pageNo: <h:outputText value="#{entityList.firstResult / entityList.maxResults + 1}"><f:convertNumber maxFractionDigits="0" groupingUsed="false" /></h:outputText>,
			callback: function(num) {
				var href = window.location.href;
				var firstResult = #{empty entityList.maxResults ? 0 : entityList.maxResults} * (num - 1);
				window.location.href = changeUrlArg(href, 'firstResult', firstResult);
			}
		});
		</script>
	</c:if>
	
	<ui:remove>
		<div class="pagination">
			<c:if test="#{entityList.previousExists}">
				<p:commandLink action="#{entityList.refresh()}" value="首页" update="@form" style="margin-left: 5px;">
					<f:setPropertyActionListener value="0" target="#{entityList.firstResult}"></f:setPropertyActionListener>
				</p:commandLink>
			</c:if>
			<c:if test="#{entityList.previousExists}">
				<p:commandLink action="#{entityList.refresh()}" value="前一页" update="@form" style="margin-left: 5px;">
					<f:setPropertyActionListener value="#{entityList.previousFirstResult}" target="#{entityList.firstResult}"></f:setPropertyActionListener>				
				</p:commandLink>
			</c:if>
			<c:if test="#{entityList.nextExists}">
				<p:commandLink action="#{entityList.refresh()}" value="后一页" update="@form" style="margin-left: 5px;">
					<f:setPropertyActionListener value="#{entityList.nextFirstResult}" target="#{entityList.firstResult}"></f:setPropertyActionListener>				
				</p:commandLink>
			</c:if>
			<c:if test="#{entityList.nextExists}">
				<p:commandLink action="#{entityList.refresh()}" value="末页" update="@form" style="margin-left: 5px;">
					<f:setPropertyActionListener value="#{entityList.lastFirstResult}" target="#{entityList.firstResult}"></f:setPropertyActionListener>				
				</p:commandLink>
			</c:if>
		</div>
	</ui:remove>
	
</ui:composition>